<template>
    <!-- 财务审核 -->
    <div>
        <el-dialog v-loading="loading" :visible.sync="isShow" :show-close="false" :fullscreen="fullscreen">
            <el-row slot="title">
                <el-col :span="10" style="padding-top: 5px">
                    <span style="font-size: 18px;">财务审核</span>
                </el-col>
                <el-col :span="2" :offset="11">
                    <el-button type="text" v-if="!fullscreen" icon="iconfont ali-quanping" @click="fullscreen = true" style="float: right"></el-button>
                    <el-button type="text" v-else icon="iconfont ali-zuixiaohua" @click="fullscreen = false" style="float: right"></el-button>
                </el-col>
                <el-col :span="1">
                    <el-button type="text" icon="iconfont ali-guanbi" @click="isShow = false" style="float: right"></el-button>
                </el-col>
            </el-row>
            <el-form :model="form" ref="form" label-width="90px">
                <el-form-item label="主题">
                    <el-input clearable style="width: 300px;" disabled v-model.trim="form.proposal_title">
                    </el-input>
                </el-form-item>
                <el-form-item label="活动封面">
                    <img v-if="form.file_path" :src="form.file_path" class="avatar">
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-form-item>
                <el-form-item label="现状描述">
                    <p v-html="form.actuality_description"></p>
                </el-form-item>
                <el-form-item label="改进方案">
                    <p v-html="form.improvement_scheme"></p>
                </el-form-item>
                <el-form-item label="效益预测">
                    <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" disabled v-model="form.benefit_calculation">
                    </el-input>
                </el-form-item>
                <el-form-item label="最终效益" prop="final_benefit" :rules="filter_rules({required:true})">
                    <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" v-model.number="form.final_benefit">
                    </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer">
                <el-button @click="isShow = false">取 消</el-button>
                <el-button type="primary" @click="validate()">提 交</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import { advice_financeAudit } from '@/api/advice'
export default {
    data() {
        return {
            loading: false,
            fullscreen: false,
            isShow: false,
            form: { final_benefit: 0 }
        }
    },
    methods: {
        show(row) {
            this.isShow = true;
            this.form = row;
        },
        validate() {
            this.$refs['form'].validate(valid => {
                if (valid) {
                    this.saveObj();
                    this.isShow = false
                } else {
                    return false;
                }
            });
        },
        async saveObj(){
            this.loading = true;
            const {data} = await advice_financeAudit({id: this.form.id,final_benefit: this.form.final_benefit})
            this.loading = false;
            if(data.status === 100){
                this.$message.success('审核成功')
                this.$emit('initList')
            }
        }
    }
}
</script>
<style lang="scss" scoped>
.avatar {
    width: 60%;
    display: block;
    border-radius: 5px;
}
</style>
